package com.leetcode.August;

/**
 * @Description: 48旋转图像
 * 先对图像进行上下翻转，然后交换对角线上下三角元素
 * @Author: Mr.Fxy
 * @CreateTime: 2024-08-22 20:27
 */
public class LC48旋转图像 {
    public void rotate(int[][] matrix) {
        int head = matrix.length;
        for (int i = 0; i < head/2; i++) {
            int[] temp = matrix[i];
            matrix[i] = matrix[head-i-1];
            matrix[head-i-1] = temp;
        }
        for (int i = 0; i < head; i++) {
            for (int j = i; j < head; j++) {
                int temp = matrix[i][j];
                matrix[i][j] = matrix[j][i];
                matrix[j][i] = temp;
            }
        }
    }
}
